package com.accenture.adf.newcodington.module12.sample;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

/**
 * 
 * Topic: Try-it using the Set data type from the Java collection framework
 * 
 * Instructions:
 * 1. Create a 'SetTryIt' class
 * 2. Create a main() method that will perform the following functions
 *    a. Create a Set using the TreeSet constructor
 *    b. Populate the Set with several elements using the add() method
 *    c. Print all the elements of the Set using the for loop and Iterator
 *    
 */

public class SetTryIt {

	public static void main(String[] args) {
		// Code to create a set of names.
		// Names will be sorted by their natural order.		
		Set<String> set=new TreeSet<String>();
		set.add("Sasha");
		set.add("John");
		set.add("Stacie");
		set.add("Mike");
		set.add("Mike");
		set.add("Peter");
		
		// Printing elements loaded in SET in console
		for(Iterator<String> iterator=set.iterator();iterator.hasNext();)
		{
			System.out.println("Elements are: "+iterator.next());
		}
		
	}
}